package com.atguigu.exer2;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

/*
    1. 利用File构造器，new 一个文件目录file
        1)在其中创建多个文件和目录
        2)编写方法，实现删除file中指定文件的操作
 */
public class FileTest1 {
    public static void main(String[] args) throws IOException {
        File file = new File("F:\\file");
        boolean mkdir = file.mkdir();
        if (mkdir) {
            System.out.println("创建成功");
        } else {
            System.out.println("创建失败");
        }

        File file1 = new File("F:\\file\\f1");
        File file2 = new File("F:\\file\\f2");
        File file3 = new File("F:\\file\\f3");
        File file4 = new File("F:\\file\\f4");

        file1.mkdir();
        file2.mkdir();
        file3.mkdir();
        file4.mkdir();

        File file5 = new File("F:\\file\\f1\\hi.txt");
        File file6 = new File("F:\\file\\f2\\why.txt");
        File file7 = new File("F:\\file\\f3\\what.txt");
        File file8 = new File("F:\\file\\f4\\how.txt");

        file5.createNewFile();
        file6.createNewFile();
        file7.createNewFile();
        file8.createNewFile();

        Scanner scan = new Scanner(System.in);
        System.out.println("请输入5-8");
        int i = scan.nextInt();


        switch (i) {
            case 5:
                file5.delete();
                break;
            case 6:
                file6.delete();
                break;
            case 7:
                file7.delete();
                break;
            case 8:
                file8.delete();
                break;
        }
    }
}